﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace BanSupport
{
    public class UnityBaseObject
    {

        //表示逻辑对象
        public GameObject go;
        //表示实体对象
        public BaseObject obj;

        public UnityBaseObject(BaseObject obj)
        {
            this.obj = obj;
            this.go = GameObject.Instantiate(Resources.Load(obj.assetName), position, rotation) as GameObject;
        }

        public virtual void Update()
        {
            if (obj != null)
            {

                go.transform.position = position;
                go.transform.rotation = rotation;
            }
            else
            {
                if (obj.destroy)
                {
                    GameObject.Destroy(go);
                    go = null;
                }
            }
        }

        public Vector3 position
        {
            get
            {
                return new Vector3((float)obj.position.x, UnityManager.Instance.globalYPos, (float)obj.position.y);
            }
        }

        public Quaternion rotation
        {
            get
            {
                return Quaternion.Euler(0, (float)obj.rotation, 0);
            }
        }

    }

}
